<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 汉诺塔 -->
    <script>
      var hanota = (A, B, C) => {
        var n = A.length
        // 将A中的n个移动到C
        var move = (n, A, B, C) => {
          if (n === 1) {
            C.push(A.pop())
            return
          }
          // 将A中的n-1个移动到B
          move(n - 1, A, C, B)
          // 将A剩余的一个移动到C
          C.push(A.pop())
          // 将B中的n-1个移动到C
          move(n - 1, B, A, C)
        }
        move(n, A, B, C)
      }
      console.log(hanota([2, 1, 0], [], []))
    </script>
  </body>
</html>
